//
//  RJOutPhotoVC.m
//  AirQuality
//
//  Created by Po on 15/5/19.
//  Copyright (c) 2015年 Po. All rights reserved.
//

#import "RJOutPhotoVC.h"

@interface RJOutPhotoVC () <UICollectionViewDelegate, UICollectionViewDataSource>
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;


- (void)initInterface;
@end

@implementation RJOutPhotoVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initInterface];
}

- (void)initInterface
{
    [self.navBar setReturnButtonHidden:NO];
    [self.navBar.centerCityLabel setText:@"实时能见度"];
    [self reSetCollectionView];
}

- (void)reSetCollectionView
{
    [_collectionView setDataSource:self];
    [_collectionView setDelegate:self];
    [_collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"outPhoto"];
    [self.view insertSubview:_collectionView aboveSubview:self.view];
}

#pragma mark - delegate
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 10;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * cellIdent = @"outPhoto";
    UICollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdent forIndexPath:indexPath];
    if (!cell) {
        NSUInteger count = indexPath.row;
        cell = [[UICollectionViewCell alloc] initWithFrame:CGRectMake(ScreenWidth / 2 * (count % 2), 220 * (count / 5), 150, 200)];
        
    }
    [cell setBackgroundColor:[UIColor redColor]];
    return cell;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(ScreenWidth / 2 - 20, ScreenWidth / 2);
}

-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
    return UIEdgeInsetsMake(20, 10, 10, 20);
}

@end
